<?php
class C_formulaire extends CI_Controller {

	public function index()
	{
		$this->load->helper(array('form', 'url'));

		$this->load->library('form_validation');
		
		$this->form_validation->set_rules('nom', 'Nom', 'trim|required|xss_clean|alpha_dash');
		$this->form_validation->set_rules('prenom', 'Prenom', 'trim|required|xss_clean|alpha_dash');
		$this->form_validation->set_rules('pseudo', 'Pseudo', 'trim|required|xss_clean|alpha_dash');
		$this->form_validation->set_rules('mdp', 'Password', 'trim|required|matches[passconf]|md5|xss_clean|alpha_dash');
		$this->form_validation->set_rules('passconf', 'Password Confirmation', 'trim|required|xss_clean|alpha_dash');
		$this->form_validation->set_rules('mail', 'Email', 'trim|required|valid_email|xss_clean');

		if ($this->form_validation->run() == FALSE)
		{
			$this->load->view('v_formulaire_inscription');
		}
		else
		{
			unset($_POST['passconf']);
			$this->load->model('membre');
			$this->membre->creation($_POST);
			$this->session->set_userdata('pseudo',$_POST['pseudo']);
			$this->load->view('v_succes');
			//$this->load->view('');
		}
	}
}
